<template>
  <a-modal 
    :visible="visible"
    :title="title"
    :maskClosable="false"
    :destroyOnClose="true"
    :keyboard="false"
    :bodyStyle="{background:'#F8F8F8',padding:'0px'}"
    @cancel="closeModal()"
    width="375px">
    <section class="main">      
      <img class="img" :src="dataInfo.imgsUrl" alt="">
      <div class="qrcode" v-if="!isShareRecord" :style="{left: shareCodeXAxis, bottom: shareCodeYAxis}">分享码区域</div>
    </section>
    <template slot="footer">
      <a-button @click="closeModal()">关闭</a-button>
    </template>
  </a-modal>
</template>
<script>
import deepCopy from '@/utils/deepCopy'
export default {
  props: {
    visible:{
      type:Boolean,
      default:false,
    },
    posterData:{
      type:Object,
      default: () => {
        return {}
      }
    },
    isShareRecord: {
      type:Boolean,
      default: false
    }
  },
  computed: {
    title () {
      return '海报预览'
    },
  },
  data () {
    return {
      dataInfo: {},
      shareCodeXAxis: '0px',
      shareCodeYAxis: '0px'
    }
  },
  watch: {
    visible(newVal){
      if(newVal){
        this.dataInfo = deepCopy(this.posterData);
        this.shareCodeXAxis = `${this.dataInfo.shareCodeXAxis}px`;
        this.shareCodeYAxis = `${this.dataInfo.shareCodeYAxis}px`;
      }
    },
  },
  created(){
    
  },
  methods: {
    closeModal () {
      this.$emit('cancel')
    }
  }
}
</script>

<style lang="less" scoped>
.main {
  width: 100%;
  position: relative;
  img {
    // width: 100%;
    display: block;
  }
  .qrcode {
    width: 160px;
    height: 160px;
    position: absolute;
    text-align: center;
    background-color: #fff;
    color: #666;
    text-align: center;
    font-size: 12px;
    line-height: 160px;
    border: 2px dashed #666;
  }
}
</style>
